# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
maintainer="Holger Jaekel <holger.jaekel@gmx.de>"
pkgname=libopendrive
pkgver=0.6.0
pkgrel=0
pkgdesc="Small, lightweight C++ library for handling OpenDRIVE files"
url="https://github.com/DLR-TS/libOpenDRIVE"
arch="all"
license="Apache-2.0"
makedepends="cmake samurai"
subpackages="$pkgname-dev"
source="libopendrive-$pkgver.tar.gz::https://github.com/DLR-TS/libOpenDRIVE/archive/refs/tags/$pkgver-gdal.tar.gz
		10-cmake_install.patch
		"
builddir="$srcdir/libOpenDRIVE-$pkgver-gdal"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None \
		$crossopts
	cmake --build build
}

check() {
	build/test-xodr test.xodr
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	rm -rf ${pkgdir:?}/usr/bin
}

sha512sums="
c6a66e6e0d80590ccb6fcec7810112156e18995da8edd45bf11d41dd6f2ac02078d1ad17f29343438ba49ce24f73fe764d6fd03a4d07435b88af0f9919ecfd30  libopendrive-0.6.0.tar.gz
a79f8cafaeba0014139b84dc8b25fc724f1aa00d36a745473837b3313e9961d5674c6c6a16d141da5d45245806b7db2aa8adb122d54bb9706f54687fabed2c72  10-cmake_install.patch
"
